
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>dubbo富客户端 | Typhoon&#39;s code space</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="typhoon">
    

    
    <meta name="description" content="富客户端(Fat Client)，是一个与瘦客户端(Thin Client)对立的概念。常见的C/S架构就是富客户端，B/S架构 是典型的瘦客户端。">
<meta property="og:type" content="article">
<meta property="og:title" content="dubbo富客户端">
<meta property="og:url" content="http://scorpioaeolus.oschina.io/2018/05/20/dubbo富客户端/index.html">
<meta property="og:site_name" content="Typhoon&#39;s code space">
<meta property="og:description" content="富客户端(Fat Client)，是一个与瘦客户端(Thin Client)对立的概念。常见的C/S架构就是富客户端，B/S架构 是典型的瘦客户端。">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f1.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f2.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f3.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/server.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f4.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f5.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/h4.jpg">
<meta property="og:updated_time" content="2018-05-25T15:23:46.548Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="dubbo富客户端">
<meta name="twitter:description" content="富客户端(Fat Client)，是一个与瘦客户端(Thin Client)对立的概念。常见的C/S架构就是富客户端，B/S架构 是典型的瘦客户端。">
<meta name="twitter:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo富客户端/f1.png">

    
    <link rel="alternative" href="/atom.xml" title="Typhoon&#39;s code space" type="application/atom+xml">
    
    
    <link rel="icon" href="/typhoon/img/java.png">
    
    
    <link rel="apple-touch-icon" href="/typhoon/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/typhoon/img/jacman.jpg">
    
    <link rel="stylesheet" href="/typhoon/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/typhoon/"><img src="/typhoon/img/java.png" alt="Typhoon&#39;s code space" title="Typhoon&#39;s code space"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/typhoon/" title="Typhoon&#39;s code space">Typhoon&#39;s code space</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/typhoon/">主页</a></li>
					
						<li><a href="/typhoon/archives">归档</a></li>
					
						<li><a href="/typhoon/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="Search" />
						<input type="hidden" name="q" value="site:scorpioaeolus.oschina.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/typhoon/2018/05/20/dubbo富客户端/" title="dubbo富客户端" itemprop="url">dubbo富客户端</a>
  </h1>
  <p class="article-author">By
       
		<a href="/typhoon/about" title="typhoon" target="_blank" itemprop="author">typhoon</a>
		
  <p class="article-time">
    <time datetime="2018-05-20T13:26:48.000Z" itemprop="datePublished"> Published 2018-05-20</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">Contents</strong>
		
			<ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#富客户端"><span class="toc-number">1.</span> <span class="toc-text">富客户端</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#瘦客户端"><span class="toc-number">2.</span> <span class="toc-text">瘦客户端</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-服务端编写"><span class="toc-number">3.</span> <span class="toc-text">I 服务端编写</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#II-消费端编写与测试"><span class="toc-number">4.</span> <span class="toc-text">II 消费端编写与测试</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#总结"><span class="toc-number">5.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#附上本人公众号"><span class="toc-number">6.</span> <span class="toc-text">附上本人公众号</span></a></li></ol>
		
		</div>
		
		<pre><code>富客户端(Fat Client)，是一个与瘦客户端(Thin Client)对立的概念。常见的C/S架构就是富客户端，B/S架构
是典型的瘦客户端。
</code></pre><a id="more"></a>
<pre><code>当然，“瘦”与“富”是相对而言，各有各自的优缺点。
</code></pre><h6 id="富客户端"><a href="#富客户端" class="headerlink" title="富客户端"></a>富客户端</h6><pre><code>优点：
    1）有一部分功能在C端可以完成，一定程度上减少了网络交互次数和开销
    2）有独立的端，可以独立运行，不依赖其他平台
    3）客户端体验好，可以完成复杂的功能
缺点：
    1）客户端占用用户资源，有时对用户硬件或者系统要求高
    2）如果服务端有更新或者升级，一般情况下C端也要跟着更新，并且更新成本高
</code></pre><h6 id="瘦客户端"><a href="#瘦客户端" class="headerlink" title="瘦客户端"></a>瘦客户端</h6><pre><code>优点：
    1）不需要用户单独下载应用C端，对用户硬件和操作系统基本无要求
    2）服务端升级，B端完全无感知
缺点：
    1）一般B端不适用于完成较复杂的功能
    2）浏览器层面的一些全局设置会影响到功能使用


    上边简单分析了常见的两种应用架构方式各自的优缺点，接下来进入主题，dubbo实现富客户端。这个概念是不太准确的，
现在分布式架构是互联网的主流，所以叫做分布式富客户端更为合适。
    那么为什么要在分布式服务中引入富客户端的概念？
    我们先看一张图：
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/f1.png" alt="dubbo" title="dubbo">
<pre><code>    如上图描述，Web层远程调用Rpc远程服务为B端(浏览器)提供服务,这样做是没有问题的，也符合当前流行的分布式架构方式；
但是高并发是所有互联网企业都要面临的问题，当然缓存是解决高并发的神器，那么如果上述架构再做一下改造如下图：
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/f2.png" alt="dubbo" title="dubbo">
<pre><code>     从改造后的图中可以看到，rpc服务暴露给调用放的client很薄，只有简单的接口定义，具体的实现还在provider层，也就是具体的
服务实现和提供者。这样上层Web层只需要引用暴露出的client利用Rpc框架就可以调用到具体的服务，在并发查询场景下，虽然引入了缓存
，但是不知道有没有人注意到，缓存是和rpc服务提供者不在一个主机甚至可能不在一个机房，Web层和Rpc服务层也可能不在一个机房，
也就是说从Web层调用Rpc服务，Rpc操作缓存都有网络开销，
     举个例子，如果Web层查询的数据在缓存中已经存在，那么回去直接从缓存中获取，但是调用链路还是Web调用Rpc服务，Rpc服务再从缓存获取数据返回，
 会有两次网络开销，我们开发者都会有一个概念，调用链路边长会增加失败的概率，在网络环境不好的情况下，一次网络开销和两次网络开销相比，体验优劣
 是很明显的。所以这种架构方式在流量大的项目中是不太可取的。
     根据上述描述，我们对方案再做改进：
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/f3.png" alt="dubbo" title="dubbo">
<pre><code>    图中加了一个步骤，Web层在调用Rpc服务之前，先去缓存拿数据，如果命中直接返回，否则继续调用Rpc服务。也就是说在缓存命中的场景下，
减少了一次网络开销。增加的节点，其实是Rpc服务的client提供的，对缓存和rpc服务的一个封装，然后暴露给调用者，也即是我们所说的富客户端的概念。

    描述了很多概念和理论性的东西，下边我们使用Dubb框架来实现富客户端。
</code></pre><h6 id="I-服务端编写"><a href="#I-服务端编写" class="headerlink" title="I 服务端编写"></a>I 服务端编写</h6><pre><code>服务端结构如下图（基于上一篇的代码）：
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/server.png" alt="dubbo" title="dubbo">
<pre><code>具体实现参考
</code></pre><blockquote><footer><strong>徒手搭建dubbo</strong><cite><a href="http://scorpioaeolus.oschina.io/typhoon/2017/12/21/%E5%BE%92%E6%89%8B%E6%90%AD%E5%BB%BAdubbo%E6%9C%8D%E5%8A%A1/">scorpioaeolus.oschina.io/typhoon/2017/12/21/%E5%BE%92%E6%89%8B%E6%90%AD%E5%BB%BAdubbo%E6%9C%8D%E5%8A%A1</a></cite></footer></blockquote>
<pre><code>在dubbo-server-interface中添加两个关键类：
</code></pre><p>CacheManager</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line">* 缓存操作类</div><div class="line">*/</div><div class="line">public class CacheManager implements TCache,InitializingBean &#123;</div><div class="line"></div><div class="line">    private  JedisPool jedisPool;</div><div class="line"></div><div class="line">    public void setJedisPool(JedisPool jedisPool) &#123;</div><div class="line">        this.jedisPool = jedisPool;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public &lt;T&gt; T get(Serializable key, Class&lt;T&gt; type) &#123;</div><div class="line"></div><div class="line">        Jedis jedis = null;</div><div class="line">        try &#123;</div><div class="line">          jedis  = jedisPool.getResource();</div><div class="line">          byte[]  data = jedis.get(key.toString().getBytes());</div><div class="line">          return SerializationUtil.deserialize(data,type);</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125; finally &#123;</div><div class="line">            if(null != jedis) &#123;</div><div class="line">                jedis.close();</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        return null;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public void put(Serializable key, Object val) &#123;</div><div class="line">        Jedis jedis = null;</div><div class="line">        try &#123;</div><div class="line">            jedis  = jedisPool.getResource();</div><div class="line">            byte[] data = SerializationUtil.serialize(val);</div><div class="line">            jedis.set(key.toString().getBytes(),data);</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125; finally &#123;</div><div class="line">            if(null != jedis) &#123;</div><div class="line">                jedis.close();</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public void afterPropertiesSet() throws Exception &#123;</div><div class="line">        if(null == jedisPool) &#123;</div><div class="line">            throw new RuntimeException(&quot;jedis没有初始化&quot;);</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>UserReadClient</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line"> * 用户信息操作客户端</div><div class="line"> *</div><div class="line"> * @author Typhoon</div><div class="line"> * @date 2018-05-20 16:04 Sunday</div><div class="line"> * @since V2.0.0</div><div class="line"> */</div><div class="line">public class UserReadClient implements InitializingBean &#123;</div><div class="line"></div><div class="line">    private static final String KEY_PREFIX = &quot;userCachePrefix:&quot;;</div><div class="line"></div><div class="line">    private CacheManager cacheManager;</div><div class="line"></div><div class="line">    private UserService userService;</div><div class="line"></div><div class="line">    public void setCacheManager(CacheManager cacheManager) &#123;</div><div class="line">        this.cacheManager = cacheManager;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public void setUserService(UserService userService) &#123;</div><div class="line">        this.userService = userService;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    /**</div><div class="line">     * 查询用户信息</div><div class="line">     *</div><div class="line">     * @param id</div><div class="line">     * @return</div><div class="line">     */</div><div class="line">    public UserDto queryByPK(Long id) &#123;</div><div class="line">        if(null == id || id &lt;= 0) &#123;</div><div class="line">            throw new IllegalArgumentException(&quot;参数非法&quot;);</div><div class="line">        &#125;</div><div class="line">        UserDto userDto = this.cacheManager.get(KEY_PREFIX + id,UserDto.class);</div><div class="line">        if(null != userDto) &#123;//走缓存</div><div class="line">            return userDto;</div><div class="line">        &#125;</div><div class="line">        //走DB</div><div class="line">        userDto = this.userService.queryByPK(id);</div><div class="line">        try &#123;</div><div class="line">            this.cacheManager.put(KEY_PREFIX + id,userDto);</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        return userDto;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public void afterPropertiesSet() throws Exception &#123;</div><div class="line">        if(null == cacheManager || null == userService) &#123;</div><div class="line">            throw new IllegalArgumentException(&quot;tCache 或者userService没有初始化 &quot;);</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>然后把dubbo-server-interface安装到本地maven仓库供其他消费端依赖，并启动服务.
</code></pre><h6 id="II-消费端编写与测试"><a href="#II-消费端编写与测试" class="headerlink" title="II 消费端编写与测试"></a>II 消费端编写与测试</h6><pre><code>  消费端redis的配置此处不做赘述，有兴趣可参见源码。
{% blockquote dubbo-consumer https://gitee.com/ScorpioAeolus/dubbo-consumer %}{% endblockquote %}
在dubbo-consumer.xml中添加远程服务引用：
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;dubbo:reference interface=&quot;com.typhoon.service.UserService&quot;  url=&quot;dubbo://localhost:20289&quot; id=&quot;userService&quot; protocol=&quot;dubbo&quot; timeout=&quot;30000&quot;/&gt;</div></pre></td></tr></table></figure>
<pre><code>在主配置文件或者其他配置中增加：
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">&lt;bean id = &quot;cacheManager&quot; class=&quot;com.typhoon.cache.CacheManager&quot;&gt;</div><div class="line">    &lt;property name=&quot;jedisPool&quot; ref=&quot;jedisPool&quot; /&gt;</div><div class="line">&lt;/bean&gt;</div><div class="line">&lt;bean id = &quot;userReadClient&quot; class=&quot;com.typhoon.client.UserReadClient&quot;&gt;</div><div class="line">    &lt;property name=&quot;cacheManager&quot; ref=&quot;cacheManager&quot; /&gt;</div><div class="line">    &lt;property name=&quot;userService&quot; ref=&quot;userService&quot; /&gt;</div><div class="line">&lt;/bean&gt;</div></pre></td></tr></table></figure>
<pre><code>然后再在本地服务中注入UserReadClient:
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">@Autowired</div><div class="line">private UserReadClient userReadClient;</div><div class="line"></div><div class="line">@Override</div><div class="line">public ResponseBase doQueryUserById(Long id) &#123;</div><div class="line">	ResponseBase resp = new ResponseBase();</div><div class="line">	UserDto userDto = this.userReadClient.queryByPK(id);</div><div class="line">	resp.setAttach(userDto);</div><div class="line">	return resp;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>编写单元测试：
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">@Test</div><div class="line">public void testA() &#123;</div><div class="line">	try &#123;</div><div class="line">		ResponseBase resp = this.imitateConsumerService.doQueryUserById(1L);</div><div class="line">		System.out.println(JSON.toJSONString(resp));</div><div class="line">	&#125; catch (Exception e) &#123;</div><div class="line">		e.printStackTrace();</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>运行单元测试并debug：
1）第一次运行
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/f4.png" alt="dubbo" title="dubbo">
<pre><code>可以看到查询没有命中缓存，走DB查询，调用了远程Rpc服务

2）第二次运行
</code></pre><img src="/typhoon/2018/05/20/dubbo富客户端/f5.png" alt="dubbo" title="dubbo">
<pre><code>debug代码看到查询命中了缓存不走DB查询，直接返回
</code></pre><h6 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h6><pre><code>    经过上述的描述和代码验证，我们使用Dubbo富客户端，其原理就是Rpc服务编写并暴露出一个复合客户端，里边包含了查询缓存和掉服务查DB的逻辑，
    但是缓存的具体配置交给调用方，这样服务调用方使用富客户端的时候会优先走自己的缓存逻辑，如果缓存不命中就继续调用Rpc服务查询，这样就解决了
并发场景虽然后走了缓存但是依旧多走一次网络开销的问题。

此篇我们根据真实业务场景讲解了dubbo泛化引用和泛化实现，希望给大家在日常开发中带来帮助！
</code></pre><p><strong><em>PS:原创不易,多多支持!</em></strong></p>
<h6 id="附上本人公众号"><a href="#附上本人公众号" class="headerlink" title="附上本人公众号"></a>附上本人公众号</h6><img src="/typhoon/2018/05/20/dubbo富客户端/h4.jpg" alt="dubbo" title="dubbo">  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/typhoon/categories/dubbo/">dubbo</a>
</div>


</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://scorpioaeolus.oschina.io/2018/05/20/dubbo富客户端/" data-title="dubbo富客户端 | Typhoon&#39;s code space" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/typhoon/2018/05/25/字符串分割性能对比/" title="字符串分割性能对比">
  <strong>上一篇：</strong><br/>
  <span>
  字符串分割性能对比</span>
</a>
</div>


<div class="next">
<a href="/typhoon/2018/05/20/dubbo泛化实现与引用/"  title="dubbo泛化实现与引用">
 <strong>下一篇：</strong><br/> 
 <span>dubbo泛化实现与引用
</span>
</a>
</div>

</nav>

	


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">Contents</strong>
 
 <ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#富客户端"><span class="toc-number">1.</span> <span class="toc-text">富客户端</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#瘦客户端"><span class="toc-number">2.</span> <span class="toc-text">瘦客户端</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-服务端编写"><span class="toc-number">3.</span> <span class="toc-text">I 服务端编写</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#II-消费端编写与测试"><span class="toc-number">4.</span> <span class="toc-text">II 消费端编写与测试</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#总结"><span class="toc-number">5.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#附上本人公众号"><span class="toc-number">6.</span> <span class="toc-text">附上本人公众号</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">Categories</p>
		<ul>
		
		  
			<li><a href="/typhoon/categories/dubbo/" title="dubbo">dubbo<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java性能优化/" title="java性能优化">java性能优化<sup>17</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java源码分析/" title="java源码分析">java源码分析<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/motan/" title="motan">motan<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/spring/" title="spring">spring<sup>11</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springboot/" title="springboot">springboot<sup>28</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springmvc/" title="springmvc">springmvc<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/容器/" title="容器">容器<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/工具/" title="工具">工具<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/性能优化/" title="性能优化">性能优化<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/架构/" title="架构">架构<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/案例分析/" title="案例分析">案例分析<sup>13</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/缓存/" title="缓存">缓存<sup>4</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/面试题/" title="面试题">面试题<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">Tags</p>
		<ul class="clearfix">
		
			
				<li><a href="/typhoon/tags/springboot/" title="springboot">springboot<sup>28</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/java性能优化/" title="java性能优化">java性能优化<sup>9</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/限流/" title="限流">限流<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring5/" title="Spring5">Spring5<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/案例分析/" title="案例分析">案例分析<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/性能优化/" title="性能优化">性能优化<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring/" title="Spring">Spring<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo/" title="dubbo">dubbo<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/分页/" title="分页">分页<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/并发/" title="并发">并发<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/异常拦截/" title="异常拦截">异常拦截<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo分布式事务/" title="dubbo分布式事务">dubbo分布式事务<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/自带图片/" title="自带图片">自带图片<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn导出mvn项目/" title="svn导出mvn项目">svn导出mvn项目<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo过滤器/" title="dubbo过滤器">dubbo过滤器<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/排序性能对比/" title="排序性能对比">排序性能对比<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/ListenableFuture/" title="ListenableFuture">ListenableFuture<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/PropertyChangeListener/" title="PropertyChangeListener">PropertyChangeListener<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jdbcTemplate高可用/" title="jdbcTemplate高可用">jdbcTemplate高可用<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">Links</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">Weibo</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m a java coder. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:ScorpioAeolus@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2019 
		
		<a href="/typhoon/about" target="_blank" title="typhoon">typhoon</a>
		
		
		</p>
</div>
</footer>
    <script src="/typhoon/js/jquery-2.0.3.min.js"></script>
<script src="/typhoon/js/jquery.imagesloaded.min.js"></script>
<script src="/typhoon/js/gallery.js"></script>
<script src="/typhoon/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>









<link rel="stylesheet" href="/typhoon/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/typhoon/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/typhoon/img/scrollup.png"/></a>
	</div>
	<script src="/typhoon/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
